\subsection{PHP 的安装}
先下载PHP：\url{http://www.php.net/downloads.php}，我用的是5.2.9版本。

PHP安装倒不复杂，只是依赖有点多。
\begin{shaded}
\begin{verbatim}
~$ sudo apt-get install flex libxml2-dev zlib1g-dev autoconf
\end{verbatim}
\end{shaded}

其中\texttt{flex}需要不低于2.5.4的版本\footnote{这里讲一件趣事，当时去找\texttt{flex} 2.5.4时，发现都是2.5.3*。去了\href{http://flex.sourceforge.net/}{官网}看发现最新版居然是2.5.35，那这个2.5.4是哪冒出来的？继续看下去才发现，在1997年发布的\texttt{flex}的版本是2.5.4a，到了2003年就变成了2.5.31，不知道这个版本号是怎么计算的\dots}。还有一个依赖是\texttt{bison}，官方文档里写的版本需求是"\texttt{1.28 (preferred), 1.35, or 1.75}"，于是我决定自己编译1.28了。到这里下载：\url{http://www.gnu.org/software/bison/}。安装过程很简单：
\begin{shaded}
\begin{verbatim}
~$ tar xzvf bison-1.28.tar.gz
~$ cd bison-1.28
~/bison-1.28$ ./configure --prefix=/usr/local
~/bison-1.28$ make
~/bison-1.28$ sudo make install
\end{verbatim}
\end{shaded}

最后就是PHP的安装了，很简单：
\begin{shaded}
\begin{verbatim}
~$ tar jxvf php-5.2.9.tar.bz2
~$ cd php-5.2.9
~/php-5.2.9$ ./configure --with-apxs2=/usr/local/apache2/bin/apxs \
> --with-mysql=/usr/local/mysql
\end{verbatim}
\end{shaded}

如果需要添加FastCGI的支持，那么编译参数应该为：
\begin{shaded}
\begin{verbatim}
~/php-5.2.9$ ./configure --with-apxs2=/usr/local/apache2/bin/apxs \
> --with-mysql=/usr/local/mysql --enable-fastcgi \
> --enable-force-cgi-redirect --disable-cli
\end{verbatim}
\end{shaded}

这步成功会显示：
\begin{shaded}
\begin{verbatim}
+--------------------------------------------------------------------+
| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE.  By continuing this installation |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+--------------------------------------------------------------------+

Thank you for using PHP.
\end{verbatim}
\end{shaded}

接着是编译：
\begin{shaded}
\begin{verbatim}
~/php-5.2.9$ make
\end{verbatim}
\end{shaded}

成功会显示：
\begin{shaded}
\begin{verbatim}
Build complete.
Don't forget to run 'make test'.
\end{verbatim}
\end{shaded}

然后是安装:
\begin{shaded}
\begin{verbatim}
~/php-5.2.9$ sudo make install
\end{verbatim}
\end{shaded}

搞定$\sim$
\subsection{PHP 的配置}
和MySQL一样，先把默认的配置文件拷过去。
\begin{shaded}
\begin{verbatim}
~/php-5.2.9$ sudo cp php.ini-dist /usr/local/lib/php.ini
\end{verbatim}
\end{shaded}

然后就是看Apache的配置文件\texttt{httpd.conf}了。检查其中是否有\texttt{LoadModule php5\_module modules/libphp5.so}这行，然后在\verb|<IfModule mime_module>|语句块中添加以下配置：
\begin{shaded}
\begin{verbatim}
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
\end{verbatim}
\end{shaded}